package com.tencreat.mall.controller.app;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tencreat.common.core.HttpResult;
import com.tencreat.common.core.controller.BaseController;
import com.tencreat.domain.mall.dto.GoodsIntegralListAppDTO;
import com.tencreat.domain.mall.vo.ResIntegralGoodsDetailsAppVO;
import com.tencreat.domain.mall.vo.ResIntegralGoodsListAppVO;
import com.tencreat.mapper.mall.MallIntegralGoodsMapper;
import com.tencreat.service.mall.IMallIntegralGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = {"7-积分商品接口"})
//@RestController
@RequestMapping("/app/api/integralGoods")
public class IntegralGoodsController extends BaseController {
    //@Autowired
    private IMallIntegralGoodsService mallIntegralGoodsService;

    //@Autowired
    MallIntegralGoodsMapper integralGoodsMapper;


    @ApiOperation("积分商品列表")
    @GetMapping("/pageList")
    public HttpResult<IPage<ResIntegralGoodsListAppVO>> list(GoodsIntegralListAppDTO dto) {
        Page<ResIntegralGoodsListAppVO> page = new Page<>(dto.getPageNum(), dto.getPageSize());
        return HttpResult.ok(mallIntegralGoodsService.pageList(page, dto));
    }

    @ApiOperation("积分商品详情")
    @GetMapping("/details")
    public HttpResult<ResIntegralGoodsDetailsAppVO> details(@ApiParam("积分商品id") @RequestParam Long id) {
        return mallIntegralGoodsService.details(id, getLoginCheck());
    }

    /**
     * 查询积分专区列表
     */
    @GetMapping("/integralZoneList")
    @ApiOperation("查询积分专区列表")
    public HttpResult<?> integralZoneList(){
        return HttpResult.ok(integralGoodsMapper.integralZoneList());
    }
}
